package com.ymatou.iapi.refund.testcase;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.optrade.parameter.enums.CancelOrderTypeEnum;
import com.ymatou.iapi.optrade.resp.Order;
import com.ymatou.iapi.optrade.resp.TradingServiceResp;
import com.ymatou.iapi.refund.parameter.CreateReturnBillBean;
import com.ymatou.iapi.refund.parameter.ProductCatalogModel;
import com.ymatou.iapi.refund.parameter.CreateReturnBillResp.ReturnBillList;
import com.ymatou.iapi.refund.parameter.UpdateReturnApplyBillNewBean;
import com.ymatou.iapi.refund.service.CreateReturnBillCall;
import com.ymatou.iapi.refund.service.UpdateReturnApplyBillNewCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.RefundCallService;
import com.ymttest.business.service.YMTTrading.TradingCallService;
import com.ymttest.business.service.YMTTrading.TradingPlaceOrderCallService;
import com.ymttest.database.model.CS_ReturnApplyBill;
import com.ymttest.database.model.CS_ReturnApplyBillLog;
import com.ymttest.database.model.CS_ReturnApplyPictures;
import com.ymttest.database.model.CS_ReturnApplyProducts;
import com.ymttest.database.model.Userinfo;
import com.ymttest.database.sqlwapper.CS_ReturnApplyBillLogWapper;
import com.ymttest.database.sqlwapper.CS_ReturnApplyBillWapper;
import com.ymttest.database.sqlwapper.CS_ReturnApplyPicturesWapper;
import com.ymttest.database.sqlwapper.CS_ReturnApplyProductsWapper;
import com.ymttest.database.sqlwapper.JUserWapper;
import com.ymttest.utils.EnvSetup;
/**
*撤销申请
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_UpdateReturnApplyBillNew{
	private static UpdateReturnApplyBillNewBean bean;
	private static UpdateReturnApplyBillNewCall call;
	private static CreateReturnBillBean createBean=new CreateReturnBillBean();
	private static CreateReturnBillCall createCall=new CreateReturnBillCall();
	private static CS_ReturnApplyBillWapper returnApplyBillWapper=new CS_ReturnApplyBillWapper();
	private static CS_ReturnApplyProductsWapper returnApplyProducts=new CS_ReturnApplyProductsWapper();
	private static CS_ReturnApplyPicturesWapper returnApplyPictures=new CS_ReturnApplyPicturesWapper();
	private static CS_ReturnApplyBillLogWapper returnApplyBillLog=new CS_ReturnApplyBillLogWapper();
	private static int hunterId=Integer.parseInt(EnvSetup.getData("autotest_seller1").toString());
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("修改退货");
	}

	@Before
	public void caseUp() {
		bean=new UpdateReturnApplyBillNewBean();
		call=new UpdateReturnApplyBillNewCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UpdateReturnApplyBillNew_001() {
		Logger.start(true,"正例-修改退货退款信息");
		try {
			//创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithLuxury(false);
			createBean=service.setCreateReturnBillBean_AcceptOrder(tradingServiceResp,tradingService,false);
			createCall=service.callCreateReturnBill(createBean,createCall);
			
			ReturnBillList returnList=createCall.getCallData().getReturnBillList().get(0);
			bean.setReturnId(returnList.getReturnId());
			bean.setUserId(createBean.getUserid());
			bean.setReturnAmount(returnList.getReturnAmount());
			bean.setReturnRemark(createBean.getReturnRemark());
			bean.setReturnReasonId(createBean.getReturnReasonId());
			
			List<String> PicUrls=new ArrayList();
			PicUrls.add("http://pic1.ymatou.com/G01/M00/3D/8C/rBBlD1siHfKAZ6HMAAUW7sFyhsM617_320_187_o.png");
			bean.setPicUrls(PicUrls);
			
			List<ProductCatalogModel> productList=new ArrayList();
			ProductCatalogModel productModel=new ProductCatalogModel();
			productModel.setCatalogId(returnList.getCatalogId());
			productModel.setReturnCount(returnList.getReturnCount());
			productList.add(productModel);
			bean.setProducts(productList);
			
			call.setData(bean);
			call.callService();			
			verifyReturn(tradingServiceResp);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UpdateReturnApplyBillNew_002() {
		Logger.start(true,"正例-修改退货退款信息-未接单，走取消流程");
		try {
			//创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithLuxury(false);
			createBean=service.setCreateReturnBillBean(tradingServiceResp,tradingService);
			createCall=service.callCreateReturnBill(createBean,createCall);
			
			ReturnBillList returnList=createCall.getCallData().getReturnBillList().get(0);
			bean.setReturnId(returnList.getReturnId());
			bean.setUserId(createBean.getUserid());
			bean.setReturnAmount(returnList.getReturnAmount());
			bean.setReturnRemark(createBean.getReturnRemark());
			bean.setReturnReasonId(createBean.getReturnReasonId());
			
			List<String> PicUrls=new ArrayList();
			PicUrls.add("http://pic1.ymatou.com/G01/M00/3D/8C/rBBlD1siHfKAZ6HMAAUW7sFyhsM617_320_187_o.png");
			bean.setPicUrls(PicUrls);
			
			List<ProductCatalogModel> productList=new ArrayList();
			ProductCatalogModel productModel=new ProductCatalogModel();
			productModel.setCatalogId(returnList.getCatalogId());
			productModel.setReturnCount(returnList.getReturnCount());
			productList.add(productModel);
			bean.setProducts(productList);
			
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("false",call.getRetData(), "验证RetData");
			Logger.verifyEquals("退单当前状态不支持修改",call.getMsg1(), "验证Msg");
			Logger.verifyEquals("500",call.getStatus(), "验证Status");
			Logger.verifyEquals("7",call.getbCode(), "验证bCode");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_UpdateReturnApplyBillNew_003() {
		Logger.start(true,"正例-修改退货退款信息-直接取消");
		try {
			//创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithLuxury(false);
			
			List<Order> orders=tradingServiceResp.getOrderList();
            long orderId=orders.get(0).getOrderId();
            long userId=tradingServiceResp.getUserId();
            //取消订单
            TradingCallService.cancelOrder(orderId,CancelOrderTypeEnum.BUYER_CANCEL_ORDER,userId);
            
			createBean=service.setCreateReturnBillBean(tradingServiceResp,tradingService);
			createCall=service.callCreateReturnBill(createBean,createCall);
			
			ReturnBillList returnList=createCall.getCallData().getReturnBillList().get(0);
			bean.setReturnId(returnList.getReturnId());
			bean.setUserId(createBean.getUserid());
			bean.setReturnAmount(returnList.getReturnAmount());
			bean.setReturnRemark(createBean.getReturnRemark());
			bean.setReturnReasonId(createBean.getReturnReasonId());
			
			List<String> PicUrls=new ArrayList();
			PicUrls.add("http://pic1.ymatou.com/G01/M00/3D/8C/rBBlD1siHfKAZ6HMAAUW7sFyhsM617_320_187_o.png");
			bean.setPicUrls(PicUrls);
			
			List<ProductCatalogModel> productList=new ArrayList();
			ProductCatalogModel productModel=new ProductCatalogModel();
			productModel.setCatalogId(returnList.getCatalogId());
			productModel.setReturnCount(returnList.getReturnCount());
			productList.add(productModel);
			bean.setProducts(productList);
			
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("null",call.getRetData(), "验证RetData");
			Logger.verifyEquals("订单"+orderId+"已取消，不能退货退款",call.getMsg1(), "验证Msg");
			Logger.verifyEquals("201",call.getStatus(), "验证Status");
			Logger.verifyEquals("1",call.getbCode(), "验证bCode");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UpdateReturnApplyBillNew_004() {
		Logger.start(true,"正例-修改退货退款信息-增加图片长度");
		try {
			//创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithLuxury(false);
			createBean=service.setCreateReturnBillBean_AcceptOrder(tradingServiceResp,tradingService,false);
			createCall=service.callCreateReturnBill(createBean,createCall);
			
			ReturnBillList returnList=createCall.getCallData().getReturnBillList().get(0);
			bean.setReturnId(returnList.getReturnId());
			bean.setUserId(createBean.getUserid());
			bean.setReturnAmount(returnList.getReturnAmount());
			bean.setReturnRemark(createBean.getReturnRemark());
			bean.setReturnReasonId(createBean.getReturnReasonId());
			
			List<String> PicUrls=new ArrayList();
			PicUrls.add("http://pic1.ymatou.com/G01/M00/3D/8C/rBBlD1siHfKAZ6HMAAUW7sFyhsM617_320_187_o.png");
			PicUrls.add("http://pic1.ymatou.com/G01/M00/3D/8C/rBBlD1siHfKAZ6HMAAUW7sFyhsM617_320_187_o1.png");
			bean.setPicUrls(PicUrls);
			
			List<ProductCatalogModel> productList=new ArrayList();
			ProductCatalogModel productModel=new ProductCatalogModel();
			productModel.setCatalogId(returnList.getCatalogId());
			productModel.setReturnCount(returnList.getReturnCount());
			productList.add(productModel);
			bean.setProducts(productList);
			
			call.setData(bean);
			call.callService();			
			verifyReturn(tradingServiceResp);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UpdateReturnApplyBillNew_005() {
		Logger.start(true,"正例-修改退货退款信息-userid不存在");
		try {
			//创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithLuxury(false);
			createBean=service.setCreateReturnBillBean_AcceptOrder(tradingServiceResp,tradingService,false);
			createCall=service.callCreateReturnBill(createBean,createCall);
			
			ReturnBillList returnList=createCall.getCallData().getReturnBillList().get(0);
			bean.setReturnId(returnList.getReturnId());
			bean.setUserId(99999);
			bean.setReturnAmount(returnList.getReturnAmount());
			bean.setReturnRemark(createBean.getReturnRemark());
			bean.setReturnReasonId(createBean.getReturnReasonId());
			
			List<String> PicUrls=new ArrayList();
			PicUrls.add("http://pic1.ymatou.com/G01/M00/3D/8C/rBBlD1siHfKAZ6HMAAUW7sFyhsM617_320_187_o.png");
			PicUrls.add("http://pic1.ymatou.com/G01/M00/3D/8C/rBBlD1siHfKAZ6HMAAUW7sFyhsM617_320_187_o1.png");
			bean.setPicUrls(PicUrls);
			
			List<ProductCatalogModel> productList=new ArrayList();
			ProductCatalogModel productModel=new ProductCatalogModel();
			productModel.setCatalogId(returnList.getCatalogId());
			productModel.setReturnCount(returnList.getReturnCount());
			productList.add(productModel);
			bean.setProducts(productList);
			
			call.setData(bean);
			call.callService();		
			
			Logger.verifyEquals("false",call.getRetData(), "验证RetData");
			Logger.verifyEquals(true,call.getMsg1().contains("此退单不属于当前请求用户"), "验证Msg");
			Logger.verifyEquals("500",call.getStatus(), "验证Status");
			Logger.verifyEquals("4",call.getbCode(), "验证bCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UpdateReturnApplyBillNew_006() {
		Logger.start(true,"正例-修改退货退款信息-修改退款金额大于之前退款金额");
		try {
			//创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithLuxury(false);
			createBean=service.setCreateReturnBillBean_AcceptOrder(tradingServiceResp,tradingService,false);
			createCall=service.callCreateReturnBill(createBean,createCall);
			
			ReturnBillList returnList=createCall.getCallData().getReturnBillList().get(0);
			bean.setReturnId(returnList.getReturnId());
			bean.setUserId(createBean.getUserid());
			bean.setReturnAmount(returnList.getReturnAmount().add(new BigDecimal(1)));
			bean.setReturnRemark(createBean.getReturnRemark());
			bean.setReturnReasonId(createBean.getReturnReasonId());
			
			List<String> PicUrls=new ArrayList();
			PicUrls.add("http://pic1.ymatou.com/G01/M00/3D/8C/rBBlD1siHfKAZ6HMAAUW7sFyhsM617_320_187_o.png");
			PicUrls.add("http://pic1.ymatou.com/G01/M00/3D/8C/rBBlD1siHfKAZ6HMAAUW7sFyhsM617_320_187_o1.png");
			bean.setPicUrls(PicUrls);
			
			List<ProductCatalogModel> productList=new ArrayList();
			ProductCatalogModel productModel=new ProductCatalogModel();
			productModel.setCatalogId(returnList.getCatalogId());
			productModel.setReturnCount(returnList.getReturnCount());
			productList.add(productModel);
			bean.setProducts(productList);
			
			call.setData(bean);
			call.callService();		
			
			
			Logger.verifyEquals(true,call.getMsg1().contains("申请退款金额不能大于实际可退款金额"), "验证Msg");
			Logger.verifyEquals("false",call.getRetData(), "验证RetData");
			Logger.verifyEquals("201",call.getStatus(), "验证Status");
			Logger.verifyEquals("1",call.getbCode(), "验证bCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UpdateReturnApplyBillNew_008() {
		Logger.start(true,"正例-修改退货退款信息-修改退款金额小于之前退款金额");
		try {
			//创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithLuxury(false);
			createBean=service.setCreateReturnBillBean_AcceptOrder(tradingServiceResp,tradingService,false);
			createCall=service.callCreateReturnBill(createBean,createCall);
			
			ReturnBillList returnList=createCall.getCallData().getReturnBillList().get(0);
			bean.setReturnId(returnList.getReturnId());
			bean.setUserId(createBean.getUserid());
			bean.setReturnAmount(returnList.getReturnAmount().subtract(new BigDecimal(1)));
			bean.setReturnRemark(createBean.getReturnRemark());
			bean.setReturnReasonId(createBean.getReturnReasonId());
			
			List<String> PicUrls=new ArrayList();
			PicUrls.add("http://pic1.ymatou.com/G01/M00/3D/8C/rBBlD1siHfKAZ6HMAAUW7sFyhsM617_320_187_o.png");
			PicUrls.add("http://pic1.ymatou.com/G01/M00/3D/8C/rBBlD1siHfKAZ6HMAAUW7sFyhsM617_320_187_o1.png");
			bean.setPicUrls(PicUrls);
			
			List<ProductCatalogModel> productList=new ArrayList();
			ProductCatalogModel productModel=new ProductCatalogModel();
			productModel.setCatalogId(returnList.getCatalogId());
			productModel.setReturnCount(returnList.getReturnCount());
			productList.add(productModel);
			bean.setProducts(productList);
			
			call.setData(bean);
			call.callService();		
			
		//	verifyReturn(tradingServiceResp);
			
			Logger.verifyEquals("true",call.getRetData(), "验证RetData");
			Logger.verifyEquals("",call.getMsg1(), "验证Msg");
			Logger.verifyEquals("200",call.getStatus(), "验证Status");
			Logger.verifyEquals("0",call.getbCode(), "验证bCode");
			
			CS_ReturnApplyBill returnApplyBill=CheckCS_CS_ReturnApplyBill(tradingServiceResp);
		    CheckCS_ReturnApplyPictures(tradingServiceResp);
		    
			Logger.comment("#### check CS_ReturnApplyBillLog ###");
			List<CS_ReturnApplyBillLog> lst=returnApplyBillLog.selectByApplyBillId(bean.getReturnId());
			for(int i=0;i<3;i++){
			    CS_ReturnApplyBillLog model=lst.get(i);

			    Logger.verifyEquals( returnApplyBill.getBuyerId(),model.getOperatorId(), "验证CS_ReturnApplyBillLog表第"+(i+1)+"条OperatorId是否正确");
			    Logger.verifyEquals(2,model.getOperatorType(), "验证CS_ReturnApplyBillLog表第"+(i+1)+"条OperatorType是否正确");
			    Logger.verifyEquals(0,model.getType(), "验证CS_ReturnApplyBillLog表第"+(i+1)+"条return(i+1)是否正确");
			    if(i==2)
			       Logger.verifyEquals(model.getReturnAmount().stripTrailingZeros().toPlainString(),bean.getReturnAmount().stripTrailingZeros().toPlainString(), "验证CS_ReturnApplyBillLog表第"+(i+1)+"条ReturnAmount是否正确");
			    else
			       Logger.verifyEquals(model.getReturnAmount().stripTrailingZeros().toPlainString(),tradingServiceResp.getPayableAmount().stripTrailingZeros().toPlainString(), "验证CS_ReturnApplyBillLog表第"+(i+1)+"条ReturnAmount是否正确");
			    if(i==0)
			        Logger.verifyEquals(model.getRemark().replace(".00", "").trim(),i==1?"":String.format("退货原因：长时间未处理订单， 退款金额：%s", String.valueOf(model.getReturnAmount().stripTrailingZeros().toPlainString())).trim(), "验证CS_ReturnApplyBillLog表第"+(i+1)+"条Remark是否正确");
			    else if(i==2)
			    	 Logger.verifyEquals(model.getRemark().replace(".00", "").trim(),i==1?"":String.format("退货原因：长时间未处理订单；退款金额：%s", String.valueOf(model.getReturnAmount().stripTrailingZeros().toPlainString())).trim(), "验证CS_ReturnApplyBillLog表第"+(i+1)+"条Remark是否正确");
			    Logger.verifyEquals(model.getAccepterLoginId(),returnApplyBill.getSellerLoginId(), "验证CS_ReturnApplyBillLog表第"+(i+1)+"条AccepterLoginId是否正确");
			  
			    Logger.verifyEquals(model.getAccepterUserId(),returnApplyBill.getSellerId(), "验证CS_ReturnApplyBillLog表第"+(i+1)+"条AccepterUserId是否正确");
			   
			    
			    Logger.verifyEquals(i!=1?1:0,model.getReturnBillAction(), "验证CS_ReturnApplyBillLog表第"+(i+1)+"条ReturnBillAction是否正确");
			    
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UpdateReturnApplyBillNew_007() {
		Logger.start(true,"正例-修改退货退款信息-修改退款金额小于之前退款金额");
		try {
			//创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithLuxury(false);
			createBean=service.setCreateReturnBillBean_AcceptOrder(tradingServiceResp,tradingService,false);
			createCall=service.callCreateReturnBill(createBean,createCall);
			
			ReturnBillList returnList=createCall.getCallData().getReturnBillList().get(0);
			bean.setReturnId(returnList.getReturnId());
			bean.setUserId(createBean.getUserid());
			bean.setReturnAmount(returnList.getReturnAmount().add(new BigDecimal(1)));
			bean.setReturnRemark(createBean.getReturnRemark());
			bean.setReturnReasonId(createBean.getReturnReasonId());
			
			List<String> PicUrls=new ArrayList();
			PicUrls.add("http://pic1.ymatou.com/G01/M00/3D/8C/rBBlD1siHfKAZ6HMAAUW7sFyhsM617_320_187_o.png");
			PicUrls.add("http://pic1.ymatou.com/G01/M00/3D/8C/rBBlD1siHfKAZ6HMAAUW7sFyhsM617_320_187_o1.png");
			bean.setPicUrls(PicUrls);
			
			List<ProductCatalogModel> productList=new ArrayList();
			ProductCatalogModel productModel=new ProductCatalogModel();
			productModel.setCatalogId(returnList.getCatalogId());
			productModel.setReturnCount(returnList.getReturnCount());
			productList.add(productModel);
			bean.setProducts(productList);
			
			call.setData(bean);
			call.callService();		
			
			Logger.verifyEquals("false",call.getRetData(), "验证RetData");
			Logger.verifyEquals(true,call.getMsg1().contains("申请退款金额不能大于实际可退款金额"), "验证Msg");
			Logger.verifyEquals("201",call.getStatus(), "验证Status");
			Logger.verifyEquals("1",call.getbCode(), "验证bCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UpdateReturnApplyBillNew_009() {
		Logger.start(true,"正例-修改退货退款信息-修改数量大于之前数量");
		try {
			//创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithLuxury(false);
			createBean=service.setCreateReturnBillBean_AcceptOrder(tradingServiceResp,tradingService,false);
			createCall=service.callCreateReturnBill(createBean,createCall);
			
			ReturnBillList returnList=createCall.getCallData().getReturnBillList().get(0);
			bean.setReturnId(returnList.getReturnId());
			bean.setUserId(createBean.getUserid());
			bean.setReturnAmount(returnList.getReturnAmount());
			bean.setReturnRemark(createBean.getReturnRemark());
			bean.setReturnReasonId(createBean.getReturnReasonId());
			
			List<String> PicUrls=new ArrayList();
			PicUrls.add("http://pic1.ymatou.com/G01/M00/3D/8C/rBBlD1siHfKAZ6HMAAUW7sFyhsM617_320_187_o.png");
			PicUrls.add("http://pic1.ymatou.com/G01/M00/3D/8C/rBBlD1siHfKAZ6HMAAUW7sFyhsM617_320_187_o1.png");
			bean.setPicUrls(PicUrls);
			
			List<ProductCatalogModel> productList=new ArrayList();
			ProductCatalogModel productModel=new ProductCatalogModel();
			productModel.setCatalogId(returnList.getCatalogId());
			productModel.setReturnCount((returnList.getReturnCount()+1));
			productList.add(productModel);
			bean.setProducts(productList);
			
			call.setData(bean);
			call.callService();		
			
			Logger.verifyEquals("false",call.getRetData(), "验证RetData");
			Logger.verifyEquals(true,call.getMsg1().contains("退款商品数量不正确"), "验证Msg");
			Logger.verifyEquals("400",call.getStatus(), "验证Status");
			Logger.verifyEquals("12",call.getbCode(), "验证bCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UpdateReturnApplyBillNew_010() {
		Logger.start(true,"正例-修改退货退款信息-修改数量大于之前数量");
		try {
			//创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithLuxury(false);
			createBean=service.setCreateReturnBillBean_AcceptOrder(tradingServiceResp,tradingService,false);
			createCall=service.callCreateReturnBill(createBean,createCall);
			
			ReturnBillList returnList=createCall.getCallData().getReturnBillList().get(0);
			bean.setReturnId(returnList.getReturnId());
			bean.setUserId(createBean.getUserid());
			bean.setReturnAmount(tradingServiceResp.getOrderList().get(0).getOrderDetailPoList().get(0).getProductPrice().multiply(new BigDecimal(returnList.getReturnCount()-1)).add(returnList.getReturnFreihtAmount()));
			bean.setReturnRemark(createBean.getReturnRemark());
			bean.setReturnReasonId(createBean.getReturnReasonId());
			
			List<String> PicUrls=new ArrayList();
			PicUrls.add("http://pic1.ymatou.com/G01/M00/3D/8C/rBBlD1siHfKAZ6HMAAUW7sFyhsM617_320_187_o.png");
			PicUrls.add("http://pic1.ymatou.com/G01/M00/3D/8C/rBBlD1siHfKAZ6HMAAUW7sFyhsM617_320_187_o1.png");
			bean.setPicUrls(PicUrls);
			
			List<ProductCatalogModel> productList=new ArrayList();
			ProductCatalogModel productModel=new ProductCatalogModel();
			productModel.setCatalogId(returnList.getCatalogId());
			productModel.setReturnCount((returnList.getReturnCount()-1));
			productList.add(productModel);
			bean.setProducts(productList);
			
			call.setData(bean);
			call.callService();		
			
			Logger.verifyEquals("true",call.getRetData(), "验证RetData");
			Logger.verifyEquals("",call.getMsg1(), "验证Msg");
			Logger.verifyEquals("200",call.getStatus(), "验证Status");
			Logger.verifyEquals("0",call.getbCode(), "验证bCode");
			
			CS_ReturnApplyBill returnApplyBill=CheckCS_CS_ReturnApplyBill(tradingServiceResp);
		    CheckCS_ReturnApplyPictures(tradingServiceResp);
		    
			Logger.comment("#### check CS_ReturnApplyBillLog ###");
			List<CS_ReturnApplyBillLog> lst=returnApplyBillLog.selectByApplyBillId(bean.getReturnId());
			for(int i=0;i<3;i++){
			    CS_ReturnApplyBillLog model=lst.get(i);

			    Logger.verifyEquals( returnApplyBill.getBuyerId(),model.getOperatorId(), "验证CS_ReturnApplyBillLog表第"+(i+1)+"条OperatorId是否正确");
			    Logger.verifyEquals(2,model.getOperatorType(), "验证CS_ReturnApplyBillLog表第"+(i+1)+"条OperatorType是否正确");
			    Logger.verifyEquals(0,model.getType(), "验证CS_ReturnApplyBillLog表第"+(i+1)+"条return(i+1)是否正确");
			    if(i==2)
			       Logger.verifyEquals(model.getReturnAmount().stripTrailingZeros().toPlainString(),bean.getReturnAmount().stripTrailingZeros().toPlainString(), "验证CS_ReturnApplyBillLog表第"+(i+1)+"条ReturnAmount是否正确");
			    else
			       Logger.verifyEquals(model.getReturnAmount().stripTrailingZeros().toPlainString(),tradingServiceResp.getPayableAmount().stripTrailingZeros().toPlainString(), "验证CS_ReturnApplyBillLog表第"+(i+1)+"条ReturnAmount是否正确");
			    if(i==0)
			        Logger.verifyEquals(model.getRemark().replace(".00", "").trim(),i==1?"":String.format("退货原因：长时间未处理订单， 退款金额：%s", String.valueOf(model.getReturnAmount().stripTrailingZeros().toPlainString())).trim(), "验证CS_ReturnApplyBillLog表第"+(i+1)+"条Remark是否正确");
			    else if(i==2)
			    	 Logger.verifyEquals(model.getRemark().replace(".00", "").trim(),i==1?"":String.format("退货原因：长时间未处理订单；退款金额：%s", String.valueOf(model.getReturnAmount().stripTrailingZeros().toPlainString())).trim(), "验证CS_ReturnApplyBillLog表第"+(i+1)+"条Remark是否正确");
			    Logger.verifyEquals(model.getAccepterLoginId(),returnApplyBill.getSellerLoginId(), "验证CS_ReturnApplyBillLog表第"+(i+1)+"条AccepterLoginId是否正确");
			  
			    Logger.verifyEquals(model.getAccepterUserId(),returnApplyBill.getSellerId(), "验证CS_ReturnApplyBillLog表第"+(i+1)+"条AccepterUserId是否正确");
			   
			    
			    Logger.verifyEquals(i!=1?1:0,model.getReturnBillAction(), "验证CS_ReturnApplyBillLog表第"+(i+1)+"条ReturnBillAction是否正确");
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UpdateReturnApplyBillNew_011() {
		Logger.start(true,"正例-修改退货退款信息-洋管家接入");
		try {
			//创建一个订单
			TradingPlaceOrderCallService tradingService = new TradingPlaceOrderCallService();
			RefundCallService service = new RefundCallService();
			TradingServiceResp tradingServiceResp = tradingService
					.placeOrderWithLuxury(false);
			createBean=service.setCreateReturnBillBean_AcceptOrder(tradingServiceResp,tradingService,false);
			createBean.setIsYMTHandle(true);
			createCall=service.callCreateReturnBill(createBean,createCall);
			
			ReturnBillList returnList=createCall.getCallData().getReturnBillList().get(0);
			bean.setReturnId(returnList.getReturnId());
			bean.setUserId(createBean.getUserid());
			bean.setReturnAmount(tradingServiceResp.getPayableAmount());
			bean.setReturnRemark(createBean.getReturnRemark());
			bean.setReturnReasonId(createBean.getReturnReasonId());
			
			List<String> PicUrls=new ArrayList();
			PicUrls.add("http://pic1.ymatou.com/G01/M00/3D/8C/rBBlD1siHfKAZ6HMAAUW7sFyhsM617_320_187_o.png");
			PicUrls.add("http://pic1.ymatou.com/G01/M00/3D/8C/rBBlD1siHfKAZ6HMAAUW7sFyhsM617_320_187_o1.png");
			bean.setPicUrls(PicUrls);
			
			List<ProductCatalogModel> productList=new ArrayList();
			ProductCatalogModel productModel=new ProductCatalogModel();
			productModel.setCatalogId(returnList.getCatalogId());
			productModel.setReturnCount(returnList.getReturnCount());
			productList.add(productModel);
			bean.setProducts(productList);
			
			call.setData(bean);
			call.callService();		
			
			Logger.verifyEquals("true",call.getRetData(), "验证RetData");
			Logger.verifyEquals("",call.getMsg1(), "验证Msg");
			Logger.verifyEquals("200",call.getStatus(), "验证Status");
			Logger.verifyEquals("0",call.getbCode(), "验证bCode");
			
		    CheckCS_CS_ReturnApplyBill(tradingServiceResp);
		    CheckCS_ReturnApplyPictures(tradingServiceResp);
			
		    Logger.comment("#### check CS_ReturnApplyPictures ###");

		    CS_ReturnApplyBill returnApplyBill=CheckCS_CS_ReturnApplyBill(tradingServiceResp);
			List<CS_ReturnApplyBillLog> lst=returnApplyBillLog.selectByApplyBillId(bean.getReturnId());
			for(int i=0;i<3;i++){
			    CS_ReturnApplyBillLog model=lst.get(i);

			    Logger.verifyEquals( returnApplyBill.getBuyerId(),model.getOperatorId(), "验证CS_ReturnApplyBillLog表第"+(i+1)+"条OperatorId是否正确");
			    Logger.verifyEquals(2,model.getOperatorType(), "验证CS_ReturnApplyBillLog表第"+(i+1)+"条OperatorType是否正确");
			    Logger.verifyEquals(0,model.getType(), "验证CS_ReturnApplyBillLog表第"+(i+1)+"条return(i+1)是否正确");
			    Logger.verifyEquals(model.getReturnAmount().stripTrailingZeros().toPlainString(),i==1?tradingServiceResp.getPayableAmount().stripTrailingZeros().toPlainString():bean.getReturnAmount().stripTrailingZeros().toPlainString(), "验证CS_ReturnApplyBillLog表第"+(i+1)+"条ReturnAmount是否正确");
			    if(i==2)
				       Logger.verifyEquals(model.getReturnAmount().stripTrailingZeros().toPlainString(),bean.getReturnAmount().stripTrailingZeros().toPlainString(), "验证CS_ReturnApplyBillLog表第"+(i+1)+"条ReturnAmount是否正确");
				    else
				       Logger.verifyEquals(model.getReturnAmount().stripTrailingZeros().toPlainString(),tradingServiceResp.getPayableAmount().stripTrailingZeros().toPlainString(), "验证CS_ReturnApplyBillLog表第"+(i+1)+"条ReturnAmount是否正确");
				    if(i==0)
				        Logger.verifyEquals(model.getRemark().replace(".00", "").trim(),i==1?"":String.format("退货原因：长时间未处理订单， 退款金额：%s", String.valueOf(model.getReturnAmount().stripTrailingZeros().toPlainString())).trim(), "验证CS_ReturnApplyBillLog表第"+(i+1)+"条Remark是否正确");
				    else if(i==3)
				    	 Logger.verifyEquals(model.getRemark().replace(".00", "").trim(),i==1?"":String.format("退货原因：长时间未处理订单；退款金额：%s", String.valueOf(model.getReturnAmount().stripTrailingZeros().toPlainString())).trim(), "验证CS_ReturnApplyBillLog表第"+(i+1)+"条Remark是否正确");
				    
			         int action=0;
			         switch(i){
				         case 0:action=1;break;
				         case 1:action=3;break;
				         case 2:action=0;break;
				         case 3:action=1;break;
			         }
			    	 Logger.verifyEquals(action,model.getReturnBillAction(), "验证CS_ReturnApplyBillLog表第"+(i+1)+"条ReturnBillAction是否正确");
			    
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	private void verifyReturn(TradingServiceResp tradingServiceResp)
	{
		Logger.verifyEquals("true",call.getRetData(), "验证RetData");
		Logger.verifyEquals("",call.getMsg1(), "验证Msg");
		Logger.verifyEquals("200",call.getStatus(), "验证Status");
		Logger.verifyEquals("0",call.getbCode(), "验证bCode");
		
		CS_ReturnApplyBill returnApplyBill=CheckCS_CS_ReturnApplyBill(tradingServiceResp);
	    CheckCS_ReturnApplyPictures(tradingServiceResp);
	    CheckCS_ReturnApplyBillLog(tradingServiceResp,returnApplyBill);
	}
	private CS_ReturnApplyBill CheckCS_CS_ReturnApplyBill(TradingServiceResp tradingServiceResp)
	{
		  Logger.comment("#### check CS_CS_ReturnApplyBill ###");
		  CS_ReturnApplyBill returnApplyBill=returnApplyBillWapper.selectByApplyBillId(bean.getReturnId()).get(0);
		  
		   Logger.verifyEquals(returnApplyBill.getReturnApplyBillId(), bean.getReturnId(), "验证CS_ReturnApplyBill表ReturnApplyBillId是否正确");
		   int sellerId=tradingServiceResp.getOrderList().get(0).getOrderPo().getSellerId().intValue();
		   Userinfo buyer=new JUserWapper().selectUserinfoByUid(bean.getUserId()).get(0);
		   Userinfo seller=new JUserWapper().selectUserinfoByUid(sellerId).get(0);
		   
		   Logger.verifyEquals(1,returnApplyBill.getAction(), "验证CS_ReturnApplyBill表Action是否正确");
		   
		   Logger.verifyEquals(returnApplyBill.getBuyerId(),bean.getUserId(), "验证CS_ReturnApplyBill表BuyerId是否正确");
		   Logger.verifyEquals(returnApplyBill.getBuyerLoginId(), buyer.getLoginId(), "验证CS_ReturnApplyBill表BuyerLoginId是否正确");
		   
		   Logger.verifyEquals(returnApplyBill.getSellerId(),Integer.parseInt(tradingServiceResp.getOrderList().get(0).getOrderPo().getSellerId().toString()), "验证CS_ReturnApplyBill表SellerId是否正确");
		   Logger.verifyEquals(returnApplyBill.getSellerLoginId(), seller.getLoginId(), "验证CS_ReturnApplyBill表SellerLoginId是否正确");
		   Logger.verifyEquals(returnApplyBill.getReturnAmount().stripTrailingZeros().toPlainString(), bean.getReturnAmount().stripTrailingZeros().toPlainString(), "验证CS_ReturnApplyBill表ReturnAmount是否正确");
		  
		   Logger.verifyEquals(returnApplyBill.getReturnRemark(), bean.getReturnRemark(), "验证CS_ReturnApplyBill表ReturnRemark是否正确");
		   Logger.verifyEquals(returnApplyBill.getCatalogId(), bean.getProducts().get(0).getCatalogId(), "验证CS_ReturnApplyBill表CatalogId是否正确");
		
		  //CS_ReturnApplyProducts
		  List<CS_ReturnApplyProducts> plst=returnApplyProducts.selectByApplyBillId(bean.getReturnId());
		  for(int i=0;i<plst.size();i++)
		  {
		    Logger.verifyEquals(bean.getProducts().get(i).getCatalogId(),plst.get(i).getCatalogId(), "验证CS_ReturnApplyProducts表第"+(i+1)+"条CatalogId是否正确");
		    Logger.verifyEquals(bean.getProducts().get(i).getReturnCount(),plst.get(i).getReturnCount(), "验证CS_ReturnApplyProducts表第"+(i+1)+"条ReturnCount是否正确");
		  }
		  return returnApplyBill;
	}
	private void CheckCS_ReturnApplyPictures(TradingServiceResp tradingServiceResp)
	{
		 //CS_ReturnApplyPictures
		Logger.comment("#### check CS_ReturnApplyPictures ###");
		   List<CS_ReturnApplyPictures> lst=returnApplyPictures.selectByApplyBillId(bean.getReturnId());
		   Logger.verifyEquals(lst.get(0).getReturnApplyBillId(), bean.getReturnId(), "验证CS_ReturnApplyPictures表ReturnApplyBillId是否正确");
		   for(int k=0;k<bean.getPicUrls().size();k++)
		   {
			   CS_ReturnApplyPictures model=lst.get(k);
			   Logger.verifyEquals(model.getImgUrl(),bean.getPicUrls().get(k), "验证CS_ReturnApplyPictures表ProductId是否正确");
			   Logger.verifyEquals(false,model.getIsDel(), "验证CS_ReturnApplyPictures表IsDel是否正确");
			}
	}
	private void CheckCS_ReturnApplyBillLog(TradingServiceResp tradingServiceResp,CS_ReturnApplyBill returnApplyBill)
	{
		Logger.comment("#### check CS_ReturnApplyBillLog ###");
		List<CS_ReturnApplyBillLog> lst=returnApplyBillLog.selectByApplyBillId(bean.getReturnId());
		for(int i=0;i<2;i++){
		    CS_ReturnApplyBillLog model=lst.get(i);

		    Logger.verifyEquals( returnApplyBill.getBuyerId(),model.getOperatorId(), "验证CS_ReturnApplyBillLog表第"+(i+1)+"条OperatorId是否正确");
		    Logger.verifyEquals(2,model.getOperatorType(), "验证CS_ReturnApplyBillLog表第"+(i+1)+"条OperatorType是否正确");
		    Logger.verifyEquals(0,model.getType(), "验证CS_ReturnApplyBillLog表第"+(i+1)+"条return(i+1)是否正确");
		    Logger.verifyEquals(model.getReturnAmount().stripTrailingZeros().toPlainString(),i==1?tradingServiceResp.getPayableAmount().stripTrailingZeros().toPlainString():bean.getReturnAmount().stripTrailingZeros().toPlainString(), "验证CS_ReturnApplyBillLog表第"+(i+1)+"条ReturnAmount是否正确");
		  
		    Logger.verifyEquals(model.getAccepterLoginId(),returnApplyBill.getSellerLoginId(), "验证CS_ReturnApplyBillLog表第"+(i+1)+"条AccepterLoginId是否正确");
		  
		    Logger.verifyEquals(model.getAccepterUserId(),returnApplyBill.getSellerId(), "验证CS_ReturnApplyBillLog表第"+(i+1)+"条AccepterUserId是否正确");
		    Logger.verifyEquals(model.getRemark().replace(".00", "").trim(),i==1?"":String.format("退货原因：长时间未处理订单， 退款金额：%s", String.valueOf(bean.getReturnAmount().stripTrailingZeros().toPlainString())).trim(), "验证CS_ReturnApplyBillLog表第"+(i+1)+"条Remark是否正确");
		    
		    Logger.verifyEquals(i==0?1:0,model.getReturnBillAction(), "验证CS_ReturnApplyBillLog表第"+(i+1)+"条ReturnBillAction是否正确");
		    
		}
	}
	
}